﻿using System;
using GraphDrawing2.V2.Concrete.Renderers;

namespace GraphDrawing2.Core
{
    public class MutableRendererFactory : IRendererFactory
    {
        IBackgroundRenderer backgroundRenderer;
        IShapeRenderer shapeRenderer;

        public void SetBackgroundRenderer(IBackgroundRenderer renderer)
        {
            backgroundRenderer = renderer;
        }

        public IBackgroundRenderer CreateBackgroundRenderer()
        {
            if (backgroundRenderer == null)
                throw new InvalidOperationException("background renderer is not set");
            return backgroundRenderer;
        }

        public void SetBoxRenderer(IShapeRenderer renderer)
        {
            shapeRenderer = renderer;
        }

        public IShapeRenderer CreateBoxRenderer()
        {
            return shapeRenderer;
        }
    }
}